package xyz.jcat.sco.admin.oauth2.server.auth;

import lombok.Getter;
import lombok.Setter;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import xyz.jcat.sco.common.LoginUser;

@Getter
@Setter
public class UserAuthenticationToken extends AbstractAuthenticationToken {

    private String username;
    private String password;
    private String captcha;

    private LoginUser loginUser;

    public UserAuthenticationToken(UserDetailsImpl userDetails) {
        super(userDetails.getAuthorities());
        this.loginUser = userDetails.getLoginUser();
        setAuthenticated(true);
    }

    public UserAuthenticationToken(String username, String password, String captcha) {
        super(null);
        this.username = username;
        this.password = password;
        this.captcha = captcha;
    }

    @Override
    public Object getCredentials() {
        return this.password;
    }

    @Override
    public Object getPrincipal() {
        return this.username;
    }
}
